package com.ywk.effective._8_transitivity;

import java.awt.*;

class ColorPointI {
    private Color color;
    private Point point;

    public ColorPointI(int x, int y, Color color) {
        point = new Point(x, y);
        this.color = color;
    }

    public Point asPoint() {
        return point;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof ColorPointI)) {
            return false;
        }
        return ((ColorPointI) obj).point.equals(this.point) && ((ColorPointI) obj).color == color;
    }

    static class Main {
        public static void main(String[] args) {
            Point point = new Point(1, 2);
            ColorPointI colorPoint = new ColorPointI(1, 2, Color.RED);
            ColorPointI colorPoint2 = new ColorPointI(1, 2, Color.RED);
            System.out.println(point.equals(colorPoint));
            System.out.println(colorPoint.equals(colorPoint));

        }
    }
}
